#include <led_heart.h>
#include <board.h>
#include "rtthread.h"
#include "rtconfig.h"
#include "main.h"
#include "drv_gpio.h"
#define LED_PIN_NUM        GET_PIN(C,  7)
static rt_thread_t led_tid = RT_NULL;


//led heart
static void led_heart(void *parameter)
{
    while(1)
    {
        rt_pin_write(LED_PIN_NUM, PIN_LOW);
        rt_thread_mdelay(100);
        rt_pin_write(LED_PIN_NUM, PIN_HIGH);
        rt_thread_mdelay(100);
        rt_pin_write(LED_PIN_NUM, PIN_LOW);
        rt_thread_mdelay(100);
        rt_pin_write(LED_PIN_NUM, PIN_HIGH);
        rt_thread_mdelay(700);
    }
}

//led heart 初始化
int led_heart_thread_init(void)
{
    rt_pin_mode(LED_PIN_NUM, PIN_MODE_OUTPUT);
    rt_pin_write(LED_PIN_NUM, PIN_HIGH);

    led_tid = rt_thread_create("led_heart",led_heart, RT_NULL,512,25, 5);

    if (led_tid != RT_NULL) {
        rt_thread_startup(led_tid);
        rt_kprintf("led_tid start\r\n");
    }
    else{
        rt_kprintf("led_tid = RT_NULL\r\n");
    }
    return RT_EOK;
}
#ifdef FINSH_USING_MSH
    MSH_CMD_EXPORT(led_heart_thread_init,led heart thread init);
#endif

